package com.laery0.xixin.controller;


import com.laery0.xixin.po.Orders;
import com.laery0.xixin.po.ResponseBean;
import com.laery0.xixin.service.OrdersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api/orders")
public class OrdersController {	
    @Autowired
	private OrdersService ordersService;

    @PostMapping("/user")
	public ResponseBean<Integer> getOrdersByUserId(@RequestBody Orders orders) {
		return ordersService.getOrdersByUserId(orders.getUserId());
	}
	
	@PostMapping("/save")
	public ResponseBean<Integer> saveOrders(@RequestBody Orders orders) {
		return ordersService.saveOrders(orders);
	}
	
	@PostMapping("/query")
	public ResponseBean<List<Orders>> listOrdersByUserId(@RequestBody Orders orders) {
		return ordersService.listOrdersByUserId(orders);
	}
	
	@PostMapping("/remove")
	public ResponseBean<Integer> removeOrders(@RequestBody Orders orders) {
		return ordersService.removeOrders(orders.getOrderId());
	}
	
	@PostMapping("/id")
	public ResponseBean<Orders> getOrdersById(@RequestBody Orders orders) {
		return ordersService.getOrdersById(orders.getOrderId());
	}
}
